package com.gzmu.storage.mapper;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.gzmu.storage.entity.Record;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xiaobo Yan
 * @since 2020-04-16
 */
@Mapper
public interface RecordMapper extends BaseMapper<Record> {
    @Insert("INSERT INTO t_record(stationid,cabinetid,chestid,name,cabinetname,chestname,serial,status,description,address," +
            "createtime,updatetime,remark) VALUES(#{stationid},#{cabinetid},#{chestid},#{name},#{cabinetname},#{chestname}," +
            "#{serial},#{status},#{description},#{address},now(),now(),#{remark}) ON DUPLICATE KEY UPDATE stationid=#{stationid}," +
            "cabinetid=#{cabinetid},chestid=#{chestid},name=#{name},cabinetname=#{cabinetname},chestname=#{chestname}," +
            "serial=#{serial},status=#{status},description=#{description},address=#{address},updatetime=now(),remark=#{remark}")
    @Options(useGeneratedKeys = true)
    boolean insertAndUpdate(Record record);

    @Update( "UPDATE t_record SET status=#{status} WHERE id=#{id}" )
    boolean updateRecodStatus(@Param( "id" ) Integer id,@Param( "status" ) Integer status);

}
